<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

//重新封装后的return json
function packJson($data='',$info='',$status=500) {
    $res = array(
        'data' => $data,
        'info' => $info,
        'status' => $status
    );
    return json($res);
}
function encode_file_contents($filename) {
	$type=strtolower(substr(strrchr($filename,'.'),1));
	
	if ('php' == $type && is_file($filename) && is_writable($filename)) { // 如果是PHP文件 并且可写 则进行压缩编码
		$contents = file_get_contents($filename); // 判断文件是否已经被编码处理
		$contents = php_strip_whitespace($filename);
		
		// 去除PHP头部和尾部标识
		$headerPos = strpos($contents,'<?php');
		$footerPos = strrpos($contents,'?>'); 
		
		$contents = substr($contents, $headerPos + 5, $footerPos - $headerPos);
		
		$encode = base64_encode(gzdeflate($contents)); // 开始编码
		
		$encode = '<?php'."\n eval(gzinflate(base64_decode("."'".$encode."'".")));\n\n?>";
		
		return file_put_contents($filename, $encode);
	}
	return false;
}

//验证用户名密码
function checkUserInfo($reg_user,$reg_pass) {
    //字母开头，允许5-16字节，允许字母数字下划线)：^[a-zA-Z][a-zA-Z0-9_]{4,15}$
    //验证用户名
    if (preg_match("/^[a-zA-Z0-9]{6,16}$/",$reg_user)) {
        //验证密码
        if (preg_match("/^[a-zA-Z]\w{5,11}$/",$reg_pass)) {
            return true;
        }
    }
    return false;
}

/**
 * 二维数组根据字段进行排序
 * @params array $array 需要排序的数组
 * @params string $field 排序的字段
 * @params string $sort 排序顺序标志 SORT_DESC 降序；SORT_ASC 升序
 */
function arraySequence($array, $field, $sort = 'SORT_DESC')
{
    $arrSort = array();
    foreach ($array as $uniqid => $row) {
        foreach ($row as $key => $value) {
            $arrSort[$key][$uniqid] = $value;
        }
    }
    array_multisort($arrSort[$field], constant($sort), $array);
    return $array;
}
//验证用户名密码
function checkNameInfo($reg_user) {
    //验证用户名
    if (preg_match("/^[a-zA-Z0-9]{6,16}$/",$reg_user)) {

        return true;

    }
    return false;
}
//验证用户名密码
function checkPassInfo($reg_pass) {
    if (preg_match("/^[a-zA-Z]\w{5,11}$/",$reg_pass)) {
        return true;
    }
    return false;
}
function checkPassInfo2($reg_pass) {
    if (preg_match("/^[a-zA-Z0-9]{5,11}$/",$reg_pass)) {
        return true;
    }
    return false;
}

function getWin($array,$key){
    $chance = array();
    foreach ($array as $v){
        $chance[] = $v[$key];
    }

    $chance_sum = array_sum($chance);
    $val = '';
    foreach ($array as $c=>$a){

        $num = mt_rand(1, $chance_sum);
        if($a['chance'] >= $num){
            $val = $c;
            break;
        }else{
            $chance_sum -= $a['chance'];
        }

    }
    return $val;
}

/**pc 蛋蛋 波色处理**/

function bose($num)
{
    $blueNum = ['2','5','8','11','17','20','23','26'];
    $greenNum = ['1','4','7','10','16','19','22','25'];
    $redNum = ['3','6','9','12','15','18','21','24'];
    $greyNum = ['0','13','14','27'];
    if(in_array($num,$blueNum))
        return '蓝';
    else if (in_array($num,$greenNum))
        return '绿';
    else if (in_array($num,$redNum))
        return '红';
    else if(in_array($num,$greyNum))
        return '灰';
}
function digit($code_num,$digit_type,$czid,$wfid=0){

    $type1 = array('4','51','61','63');
    if(in_array($czid, $type1)){
        $digit = ['第一位','第二位','第三位','第四位','第五位','第六位','第七位','第八位','第九位','第十位'];
    }else{
        $digit = ['万位','千位','百位','十位','个位'];
    }
    switch($wfid){
        case 294:
            $digit = ['第一球','第二球','第三球','第四球','第五球'];
            break;
        case 295:
            $digit = ['龙虎','第一球','第二球','第三球','第四球','第五球'];
            break;
        case 297:
            $digit = ['总和值','万位','千位','百位','十位','个位'];
            break;
        case 298:
            $digit = ['前三','中三','后三'];
            break;
    }
    $digit_data = explode(',', $digit_type);
    $code = explode(',', $code_num);
    $data = '';

    foreach ($code as $key=>&$code_val){

        if( '0'!=preg_replace('# #','',$code_val) && empty(preg_replace('# #','',$code_val))){
            continue;
        }
        $data = $data.$digit[$digit_data[$key]].'('.str_replace(' ','|',trim($code_val)).')';
    }
    return $data;
}
function digit_pl($pl_num,$digit_type,$czid,$wfid=0){

    $type1 = array('4','51','61','63');
    if(in_array($czid, $type1)){
        $digit = ['第一位','第二位','第三位','第四位','第五位','第六位','第七位','第八位','第九位','第十位'];
    }else{
        $digit = ['万位','千位','百位','十位','个位'];
    }
    switch($wfid){
        case 294:
            $digit = ['第一球','第二球','第三球','第四球','第五球'];
            break;
        case 295:
            $digit = ['龙虎','第一球','第二球','第三球','第四球','第五球'];
            break;
        case 297:
            $digit = ['总和值','万位','千位','百位','十位','个位'];
            break;
        case 298:
            $digit = ['前三','中三','后三'];
            break;
    }
    $digit_data = explode(',', $digit_type);
    $code = explode('|', $pl_num);
    $data = '';

    foreach ($code as $key=>&$code_val){

        if( '0'!=preg_replace('# #','',$code_val) && empty(preg_replace('# #','',$code_val))){
            continue;
        }
        $data = $data.$digit[$digit_data[$key]].'('.str_replace(' ','|',trim($code_val)).')';
    }
    return $data;
}


function Hk6bose($num)
{
    $redNum = ['01','02','07','08','12','13','18','19','23','24','29','30','34','35','40','45','46'];
    $greenNum = ['05','06','11','16','17','21','22','27','28','32','33','38','39','43','44','49'];
    $blueNum = ['03','04','09','10','14','15','20','25','26','31','36','37','41','42','47','48'];
    if(in_array($num,$blueNum))
        return '蓝';
    else if (in_array($num,$greenNum))
        return '绿';
    else if (in_array($num,$redNum))
        return '红';
}

//标记六合彩球对应样式
function lhcTrans($kjjg) {
    foreach($kjjg as $v) {
        if (in_array($v,array('01','02','07','08','12','13','18','19','23','24','29','30','34','35','40','45','46'))) {
            $res[] = 'red';
        } elseif (in_array($v,array('05','06','11','16','17','21','22','27','28','32','33','38','39','43','44','49'))) {
            $res[] = 'green';
        }elseif (in_array($v,array('03','04','09','10','14','15','20','25','26','31','36','37','41','42','47','48'))) {
            $res[] = 'blue';
        }
    }
    return $res;
}

/**
 * 验证手机号是否正确
 * 移动：134、135、136、137、138、139、150、151、152、157、158、159、182、183、184、187、188、178(4G)、147(上网卡)、172、198、148、165
 * 联通：130、131、132、155、156、185、186、176(4G)、145(上网卡)、171、175、166、146
 * 电信：133、153、173、180、181、189 、177(4G)、149、199
 * 卫星通信：1349
 * 虚拟运营商：170、171
 */
function checkPhone($phone) {
    if (!is_numeric($phone)) {
        return false;
    }
    return preg_match('#^13[\d]{9}$|^14[5,6,7,8,9]{1}\d{8}$|^15[^4]{1}\d{8}$|^16[5,6]{1}\d{8}$|^17[0,1,2,3,5,6,7,8]{1}\d{8}$|^18[\d]{9}$|^19[8,9]{1}\d{8}$#', $phone) ? true : false;
}
//手机和电脑访问判断
function computer_or_mobile()
{
    $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : '';
    $mobile_browser = 0;
    $condition = preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', strtolower($_SERVER['HTTP_USER_AGENT']));
    if($condition) $mobile_browser++;
    if((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') !== false)) $mobile_browser++;
    if(isset($_SERVER['HTTP_X_WAP_PROFILE'])) $mobile_browser++;
    if(isset($_SERVER['HTTP_PROFILE'])) $mobile_browser++;

    $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
    $mobile_agents = array(
        'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
        'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
        'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
        'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
        'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
        'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
        'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
        'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
        'wapr','webc','winw','winw','xda','xda-'
    );

    if(in_array($mobile_ua, $mobile_agents)) $mobile_browser++;
    if(strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) $mobile_browser++;
    if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') !== false) $mobile_browser=0;
    if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows phone') !== false) $mobile_browser++;

    if($mobile_browser>0) {
        $fwdkzt="mobile";
    } else {
        $fwdkzt="computer";
    }
    return $fwdkzt;
}


function p($data)
{
    echo '<pre>' . print_r($data, true) . '<pre>';exit();
}

//取访问ip
function get_ip()
{
    if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) {
        $ip = getenv("HTTP_CLIENT_IP");
    } else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) {
        $ip = getenv("HTTP_X_FORWARDED_FOR");
    } else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) {
        $ip = getenv("REMOTE_ADDR");
    } else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) {
        $ip = $_SERVER['REMOTE_ADDR'];
    } else {
        $ip = "unknown";
    }
    return($ip);
}

//随机字符
function suiji_zifu($light)
{
    $return_fh = '';
    $old_zifu = "qwertyuiopasdfghjklzxcvbnmABCDEFQWERTYUIOPASDFGHJKLZXCVBNM";
    for($i=0;$i<$light;$i++) {
        $return_fh = $return_fh.substr($old_zifu,rand(0,61),1);
    }
    return $return_fh;

}

//开奖结果分割
function kjjg_split($kjhm,$czid,$string=false) {
    $res = array();
    //PC蛋蛋特殊处理
    if(strlen($kjhm)>1){
        if($czid == 10) {
            $tmp = explode('=',$kjhm);
            $res = str_split($tmp[0],1);
            $res[] = '=';
            if($tmp[1] < 10) {
                $tmp[1] = '0'.$tmp[1];
            }
            $res[] = $tmp[1];
        } else {
            //按照配置键名键值分割
            $split_arr = config('kjjg_split');
            foreach($split_arr as $k=>$v) {
                if(in_array($czid,$v)) {
                    $res = str_split($kjhm,$k);
                }
            }
        }
    }
    //输出逗号拼接的字符串
    if($string) {
        $res = join(',',$res);
    }
    return $res;
}

//开奖结果转换为彩色号码球(前端则调整尺寸)
function kjjg_or_img($kjhm,$czid,$size=25)
{
    $fanhuidm = '';
    //时时彩类开奖结果处理 // 5个号码  0-9
    if($czid==1 || $czid==8 || $czid==62) {
        if($kjhm < 1) {
            $fanhuidm = "
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
		 	";
        } else {
            for($counts=0;$counts<5;$counts++) {
                $hmq = substr($kjhm,$counts,1);
                $hm_img = "__ATTACHMENT__/img/qiu_2/20{$hmq}.png";
                $fanhuidm .= "<img src='{$hm_img}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
            }
        }
    }

    //北京赛车类开奖结果处理 // 10个号码 01-10
    if($czid==4 || $czid==61 || $czid==63) {
        if($kjhm < 1) {
            $fanhuidm = "
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:2px'  />
			 ";
        } else {
            for($counts=0;$counts<20;$counts++) {
                if($counts%2 == 0) {
                    $hmq = substr($kjhm,$counts,2);
                    $hm_img = "__ATTACHMENT__/img/qiu_3/1{$hmq}.png";
                    $fanhuidm .= "<img src='{$hm_img}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
                }
            }
        }
    }

    //排列三类开奖结果处理 // 3个号码 0-9
    if($czid==5 || $czid==48 || $czid==7 || $czid==36 || $czid==44 || $czid==48 || $czid==72) {
        if($kjhm < 1) {
            $fanhuidm = "
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 ";
        } else {
            for($counts=0;$counts<3;$counts++) {
                $hmq = substr($kjhm,$counts,1);
                $hm_img = "__ATTACHMENT__/img/qiu_2/20{$hmq}.png";
                $fanhuidm .= "<img src='{$hm_img}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
            }
        }
    }

    //六合彩专用处理
    if($czid == 9) {
        if($kjhm < 1) {
            $fanhuidm = "
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_3/253.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 ";
        } else {
            for($counts=0;$counts<14;$counts++) {
                if($counts%2 == 0) {
                    $hmq = substr($kjhm,$counts,2);
                    $hm_img = "__ATTACHMENT__/img/qiu_lhc/{$hmq}.png";
                    $fanhuidm .= "<img src='{$hm_img}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
                }
            }
        }
    }
    //PC蛋蛋
    if($czid == 10) {
        if($kjhm < 1) {
            $fanhuidm = "
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/252.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 ";
        } else {
            $open_over = explode("=",$kjhm);
            for($counts=0;$counts<3;$counts++){
                $hmq = substr($open_over[0],$counts,1);
                $hm_img = "__ATTACHMENT__/img/qiu_2/20{$hmq}.png";
                $fanhuidm .= "<img src='{$hm_img}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
            }
            $fanhuidm .= "<img src='__ATTACHMENT__/img/qiu_2/252.png' width='".$size."' height='".$size."' style='margin-left:5px'  />";
            if($open_over[1] < 10) {
                $open_over[1] = "0".$open_over[1];
            }
            $hm_imgs = "__ATTACHMENT__/img/qiu_2/2{$open_over[1]}.png";
            $fanhuidm .= "<img src='{$hm_imgs}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
        }
    }

    //11选5
    if($czid==16 || $czid==25 || $czid==28) {
        if($kjhm < 1) {
            $fanhuidm = "
			 <img src = '__ATTACHMENT__/img/qiu_1/252.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_1/252.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_1/252.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_1/252.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_1/252.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 ";
        } else {
            for($counts=0;$counts<10;$counts++) {
                if($counts%2 == 0){
                    $hmq = substr($kjhm,$counts,2);
                    $hmq = floor($hmq);
                    $hm_img = "__ATTACHMENT__/img/qiu_1/{$hmq}.png";
                    $fanhuidm .= "<img src='{$hm_img}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
                }
            }
        }
    }

    //七星彩
    if($czid == 51) {
        if($kjhm < 1) {
            $fanhuidm = "
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 <img src = '__ATTACHMENT__/img/qiu_2/251.png' width='".$size."' height='".$size."' style='margin-left:5px'  />
			 ";
        } else {
            for($counts=0;$counts<7;$counts++) {
                $hmq = substr($kjhm,$counts,1);
                $hm_img = "__ATTACHMENT__/img/qiu_2/20{$hmq}.png";
                $fanhuidm .= "<img src='{$hm_img}' width='".$size."' height='".$size."' style='margin-left:5px'  />";
            }
        }
    }

    return $fanhuidm;
}


//号码分割
function hmq_qg($kjjg,$czid) {
    $shuzucount = 0;
    if($czid==1 || $czid==2 || $czid==3 || $czid==6 || $czid==8 || $czid==11 || $czid==12 || $czid==52 || $czid==53 || $czid==54 || $czid==62) {
        for($counts=0;$counts<5;$counts++) {
            $shuzucount += 1;
            $hmq = substr($kjjg,$counts,1);
            $hmq = floor($hmq);
            $hmarray[$shuzucount] = $hmq;
        }
    }
    if($czid==4 || $czid==56  || $czid==61 || $czid==63) {
        for($counts=0;$counts<20;$counts++) {
            if($counts%2 == 0) {
                $shuzucount += 1;
                $hmq = substr($kjjg,$counts,2);
                $hmq = floor($hmq);
                $hmarray[$shuzucount] = $hmq;
            }
        }
    }
    if($czid==5 || $czid==48 || $czid==7 || $czid==36 || $czid==37 || $czid==38 || $czid==39 || $czid==40 || $czid==41 || $czid==42 || $czid==43 || $czid==44 || $czid==72 || $czid==45 || $czid==46 || $czid==47 || $czid==48 || $czid==57) {
        for($counts=0;$counts<3;$counts++) {
            $hmq = substr($kjjg,$counts,1);
            $hmq = floor($hmq);
            $shuzucount += 1;
            $hmarray[$shuzucount] = $hmq;
        }
    }
    if($czid == 9 || $czid==73) {
        for($counts=0;$counts<14;$counts++) {
            if($counts%2 == 0) {
                $hmq = substr($kjjg,$counts,2);
                $hmq = floor($hmq);
                $shuzucount += 1;
                $hmarray[$shuzucount] = $hmq;
            }
        }
    }
    //PC蛋蛋
    if($czid == 10){
        $open_over = explode('=',$kjjg);
        for($counts=0;$counts<3;$counts++) {
            $hmq = substr($open_over[0],$counts,1);
            $hmq = floor($hmq);
            $shuzucount += 1;
            $hmarray[$shuzucount] = $hmq;
        }
    }
    //11选5
    if($czid==13 || $czid==14 || $czid==15 || $czid==16 || $czid==17 || $czid==18 || $czid==19 || $czid==20 || $czid==21 || $czid==22 || $czid==23 || $czid==24 || $czid==25 || $czid==26 || $czid==27 || $czid==28 || $czid==29 || $czid==31 || $czid==32 || $czid==33 || $czid==34 || $czid==35 || $czid==58) {
        for($counts=0;$counts<10;$counts++) {
            if($counts%2 == 0) {
                $hmq = substr($kjjg,$counts,2);
                $hmq = floor($hmq);
                $shuzucount += 1;
                $hmarray[$shuzucount] = $hmq;
            }
        }
    }
    //广东快乐十分、幸运农场、天津快乐十分
    if($czid == 49 || $czid == 59) {
        for($counts=0;$counts<16;$counts++) {
            if($counts%2==0) {
                $hmq = substr($kjjg,$counts,2);
                $hmq = floor($hmq);
                $shuzucount += 1;
                $hmarray[$shuzucount] = $hmq;
            }
        }
    }
    //七星彩
    if($czid == 51) {
        for($counts=0;$counts<7;$counts++) {
            $hmq = substr($kjjg,$counts,1);
            $hmq = floor($hmq);
            $shuzucount += 1;
            $hmarray[$shuzucount] = $hmq;
        }
    }
    //双色球
    if($czid == 50) {
        for($counts=0;$counts<14;$counts++) {
            if($counts%2 == 0) {
                $hmq = substr($kjjg,$counts,2);
                $hmq = floor($hmq);
                $shuzucount += 1;
                $hmarray[$shuzucount] = $hmq;
            }
        }
    }
    //北京快乐8
    if($czid == 60) {
        for($counts=0;$counts<40;$counts++) {
            if($counts%2==0) {
                $hmq = substr($kjjg,$counts,2);
                $hmq = floor($hmq);
                $shuzucount += 1;
                $hmarray[$shuzucount] = $hmq;
            }
        }
    }

    return $hmarray;
}


//js网址跳转并提示
function js_tishi($test,$url) {
    $tishi_js = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><script language="javascript">';
    if($test != '') {
        $tishi_js = $tishi_js."alert('$test');";
    }
    if($url != '') {
        $tishi_js = $tishi_js."this.location.replace('$url');";
    }
    $tishi_js = $tishi_js."</script></html>";
    echo $tishi_js;
}
function js_tishi_tan($test,$url) {
    $tishi_js = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><script language="javascript">';
    if($test != '') {
        $tishi_js = $tishi_js."alert('$test');";
    }
    if($url != '') {
        $tishi_js = $tishi_js."this.parent.location.replace('$url');";
    }
    $tishi_js = $tishi_js."</script></html>";
    echo $tishi_js;
}

//js失败提示
function alert_back($msg){
    echo '<script>alert("'.$msg.'");history.back();</script>';
    exit();
}
//未登录（Android）
function android_login($msg,$from){

    if( 1==$from ){
        echo "<script>jump2app.alertDialog('{$msg}');jump2app.jump2LoginActivity();jump2app.destroyWebActivity();</script>";
    }else{
        $string = "function setupWebViewJavascriptBridge(callback) {
                                if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
                                if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
                                window.WVJBCallbacks = [callback];
                                var WVJBIframe = document.createElement('iframe');
                                WVJBIframe.style.display = 'none';
                                WVJBIframe.src = 'https://__bridge_loaded__';
                                document.documentElement.appendChild(WVJBIframe);
                                setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
                            }";
        $string .= "setupWebViewJavascriptBridge(function(bridge) {
                                /* Initialize your app here */
                                bridge.registerHandler('JS Echo', function(data, responseCallback) {
                                    responseCallback(data)
                                })
                                bridge.callHandler('jumpToLogin', {'key':'value'}, function responseCallback(responseData) {
                                })
                            })".PHP_EOL;
        $string .= "WebViewJavascriptBridge.callHandler('jumpToLogin');";
        echo "<script>alert('{$msg}');".$string."</script>";
    }
    return;
}
//回退个人中心（Android）
function android_member($msg,$from){
    if( 1==$from ){
        echo '<script>jump2app.alertDialog("'.$msg.'");jump2app.destroyWebActivity();</script>';
    }else{
        $string = "function setupWebViewJavascriptBridge(callback) {
                                if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
                                if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
                                window.WVJBCallbacks = [callback];
                                var WVJBIframe = document.createElement('iframe');
                                WVJBIframe.style.display = 'none';
                                WVJBIframe.src = 'https://__bridge_loaded__';
                                document.documentElement.appendChild(WVJBIframe);
                                setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
                            }";
        $string .= "setupWebViewJavascriptBridge(function(bridge) {
                                /* Initialize your app here */
                                bridge.registerHandler('JS Echo', function(data, responseCallback) {
                                    responseCallback(data)
                                })
                                bridge.callHandler('backClick', {'key':'value'}, function responseCallback(responseData) {
                                })
                            })".PHP_EOL;
        $string .= "WebViewJavascriptBridge.callHandler('backClick');";
        echo "<script>alert('.$msg.');".$string."</script>";
    }
    exit();
}
function mobile_tishi($test,$url,$from) {
    $tishi_js = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><script language="javascript">';

    if($test != '') {
        if( 1==$from ){
            $tishi_js .= 'jump2app.alertDialog("'.$test.'");';
        }else{
            $tishi_js .= "function setupWebViewJavascriptBridge(callback) {
                                if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
                                if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
                                window.WVJBCallbacks = [callback];
                                var WVJBIframe = document.createElement('iframe');
                                WVJBIframe.style.display = 'none';
                                WVJBIframe.src = 'https://__bridge_loaded__';
                                document.documentElement.appendChild(WVJBIframe);
                                setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
                            }";
            $tishi_js .= "setupWebViewJavascriptBridge(function(bridge) {
                                /* Initialize your app here */
                                bridge.registerHandler('JS Echo', function(data, responseCallback) {
                                    responseCallback(data)
                                })
                                bridge.callHandler('backClick', {'key':'value'}, function responseCallback(responseData) {
                                })
                            })".PHP_EOL;
            $tishi_js .= "alert('{$test}');";
            $tishi_js .= "WebViewJavascriptBridge.callHandler('backClick');";
        }
    }
    if($url != '') {
        $tishi_js .= "this.location.replace('$url');";
    }
    $tishi_js .= "</script></html>";
    echo $tishi_js;
}
function mobile_alert($test,$url,$from) {
    $tishi_js = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><script language="javascript">';

    if($test != '') {
        if( 1==$from ){
            $tishi_js .= 'jump2app.alertDialog("'.$test.'");';
        }else{
            $tishi_js .= "alert('{$test}');";
        }
    }
    if($url != '') {
        $tishi_js .= "window.history.go(-1);";
    }
    $tishi_js .= "</script></html>";
    echo $tishi_js;
}
//数组排序
function multi_array_sort($multi_array,$sort_key,$sort=SORT_DESC) {
    if(is_array($multi_array)) {
        foreach ($multi_array as $row_array) {
            if(is_array($row_array)) {
                $key_array[] = $row_array[$sort_key];
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
    array_multisort($key_array,$sort,$multi_array);
    return $multi_array;

}


//提示文本
function admin_text($num) {
    if(!$num) return '';
    $admin_test = array();
    $admin_test[0] = "登录成功！";
    $admin_test[1] = "账号或密码出现错误！";
    $admin_test[2] = "退出成功！";
    $admin_test[3] = "参数不全！";
    $admin_test[4] = "管理员登录成功";
    $admin_test[5] = "修改了平台版权与logo信息";
    $admin_test[6] = "操作成功！";
    $admin_test[7] = "当前无风格";
    $admin_test[9] = "修改电脑版与手机版的风格设置";
    $admin_test[10] = "管理操作";
    $admin_test[11] = "会员操作";
    $admin_test[12] = "关闭了网站并修改关闭说明";
    $admin_test[13] = "开启了网站并修改关闭说明";
    $admin_test[14] = "修改了客服连接";
    $admin_test[15] = "修改了网站统计代码";
    $admin_test[16] = "修改了充值赠送金额设置";
    $admin_test[17] = "修改会员提现设置信息";
    $admin_test[18] = "修改了充值自动增加打码量设置";
    $admin_test[19] = "修改了注册防骚扰设置";
    $admin_test[20] = "修改了充值防骚扰设置";
    $admin_test[21] = "修改了注册设置";
    $admin_test[22] = "修改了投注模式功能";
    $admin_test[23] = "修改了试玩账号设置";
    $admin_test[24] = "当前无选定提示音";
    $admin_test[25] = "修改了网站后台提示声音";
    $admin_test[26] = "操作错误，该操作为重复操作！";
    $admin_test[27] = "异常订单，请进行已阅读操作，不能进行入款！";
    $admin_test[28] = "操作成功，数据过多系统设定每次只删除一万条！";
    $admin_test[29] = "操作错误，已有管理正在审核！";
    $admin_test[30] = "操作错误，已有管理员在处理或者还未进行审核！";
    $admin_test[31] = "用户名不存在，或者账号为内部账号！";
    $admin_test[32] = "请输入正确的数字，例如：100！";
    $admin_test[33] = "用户名不存在，或者不是内部账号！";
    $admin_test[34] = "修改了代理资料";
    $admin_test[35] = "清空了全部内部账号";
    $admin_test[36] = "清空了所有内部账号的充值提现投注记录";
    $admin_test[37] = "清空了内部账号的记录，账号：";
    $admin_test[38] = "删除了内部账号：";
    $admin_test[39] = "修改了内部账号资料，账号：";
    $admin_test[40] = "一键删除了试玩账号";
    $admin_test[41] = "默认会员等级不能删除！";
    $admin_test[42] = "删除了会员等级";
    $admin_test[43] = "新增了一个会员等级";
    $admin_test[44] = "用户名已经存在！";
    $admin_test[45] = "手工退款错误，截止时间未到不能退款！";
    $admin_test[46] = "对不起会员等级的充值方案已经存在，请先删除会员等级的充值在添加！";
    $admin_test[47] = "新增的管理员账号已经存在！";
    $admin_test[48] = "无权限操作！";
    $admin_test[49] = "会员登录网站！";
    $admin_test['banquan'] = "网投彩票系统版权所有，联系SkyPe：zycpfw@sina.com";
    return $admin_test[$num];
}

//前端投注代码生成
function count_touzhudm_mobile($count_tid,$big_tid,$peilv) {
    $touzhu_dm = '';
    for($t=$count_tid;$t<=$big_tid;$t++) {
        $hm_if = $t;
        if($hm_if < 10) {
            $hm_if = '0'.$hm_if;
        }
        $touzhu_dm = $touzhu_dm."


		<div class='num_table_ball' style='margin-left: 34px;'>
			 	  <a id='hmxz_xz_{$t}' style='margin-left: 15px;' class='ball_5  ball_41207'>{$hm_if}</a>
             <span class='prize' id='TeSe_WanFa_{$t}' style='width: 100%;height: 100%;font-size: 0.75rem;position: absolute;top: 3px;left: 0px;text-align: center;line-height: 66px;'>{$peilv}</span><span class='bet-input-0 ip-bet' style='display: inline-block;width: 50px;position: absolute;top: 12px;left: 51px;'>
             <input style='    width: 41px;height: 25px;' type='text' id='hmxz_je_{$t}' value='' onKeyUp='if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')};jishuan_zhushu_zidong();' onafterpaste='if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')};jishuan_zhushu_zidong();'></span>

			 </div>
		";
    }
    return $touzhu_dm;

}


function checkorderstatus($ordid){
    $Ord=model('ssc_orderlist');
    $ordstatus=$Ord->where('ordid='.$ordid)->getField('ordstatus');
    if($ordstatus==1){
        return true;
    }else{
        return false;
    }
}
//处理订单函数
//更新订单状态，写入订单支付后返回的数据
function orderhandle($parameter){
    $ordid=$parameter['out_trade_no'];
    $data['payment_trade_no']      =$parameter['trade_no'];
    $data['payment_trade_status']  =$parameter['trade_status'];
    $data['payment_notify_id']     =$parameter['notify_id'];
    $data['payment_notify_time']   =$parameter['notify_time'];
    $data['payment_buyer_email']   =$parameter['buyer_email'];
    $data['ordstatus']             =1;
    $Ord=model('Orderlist');
    $Ord->where('ordid='.$ordid)->save($data);
}
/*-----------------------------------
 2013.8.13更正
下面这个函数，其实不需要，大家可以把他删掉，
具体看我下面的修正补充部分的说明
------------------------------------*/
//获取一个随机且唯一的订单号；
function getordcode(){
    $Ord=model('ssc_orderlist');
    $numbers = range (10,99);
    shuffle ($numbers);
    $code=array_slice($numbers,0,4);
    $ordcode=$code[0].$code[1].$code[2].$code[3];
    $oldcode=$Ord->where("ordcode='".$ordcode."'")->getField('ordcode');
    if($oldcode){
        getordcode();
    }else{
        return $ordcode;
    }
}



//验证投注号码金额
function touzhuhaoma_jine_code($tzhm) {
    $zhenshi_tzjme = 0;
    $zhenshi_zongtzje = 0;
    $jubu_fenge_1 = explode('[H]',$tzhm);
    foreach($jubu_fenge_1 as $xh_1) {
        $jubu_fenge_2 = explode('[SH]',$xh_1);
        if(count($jubu_fenge_2) == 2) {
            $jubu_fenge_3 = explode('[G]',$jubu_fenge_2[1]);
            if(count($jubu_fenge_3) == 8) {
                $tzjme = $jubu_fenge_3[3]*$jubu_fenge_3[4];
                if($jubu_fenge_3[1] == '1') $zhenshi_tzjme = $tzjme;
                if($jubu_fenge_3[1] == '2') $zhenshi_tzjme = $tzjme/10;
                if($jubu_fenge_3[1] == '3') $zhenshi_tzjme = $tzjme/100;
            }
            if($jubu_fenge_3[2] == $zhenshi_tzjme) {
                $zhenshi_zongtzje = $zhenshi_zongtzje + $zhenshi_tzjme;
            }
        }
    }
    return $zhenshi_zongtzje;
}

/**
 * * added by lss@2017/07/24
 * * 开奖数据格式化
 * * @param $value[string 开奖数据]
 * * return array
 */
function getCodeArr($value)
{
    $ret = array();
    $orig = array(
        " ",
        "　",
        "\t",
        "\n",
        "\r",
        "+"
    );
    $new = array(
        "",
        "",
        "",
        "",
        "",
        ","
    );
    $codes = str_replace($orig, $new, $value);
    $ret = explode(',', $codes);
    return $ret;
}
/**
 ** 对开奖数据的一些分析【求和 比较大小  龙虎】
 **/
function getBigOrSmall($value, $threshold, $sum='')
{
    $ret = '小';
    if(!empty($sum) && $value == $sum) $ret = '和'; else if ($value > $threshold) $ret = '大';
    return $ret;
}
function getEvenOrOdd($value)
{
    $ret = '单';
    if ($value % 2 == 0) $ret = '双';
    return $ret;
}
function szt($arr,$pid=0,$lev=0){
    static $i = 2;
    static $category = ['',[]];
    static $cate_arr='';
    static $xiaoji = ['je'=>0,'dlyj'=>'0','zjzje'=>0,'dml'=>0,'zcjje'=>0,'czzje'=>0,'tzzje'=>0,'txzje'=>0];
    if(is_array($arr)){
        foreach ($arr as &$v){
            if($v['dl']==1){$v['mc']="(代理)";$v['je']=0;}else{$v['mc']="(会员)";$v['je']=$v['je'];}
            if($v['tjrid']==$pid){
                $cate_arr .= "<tr class=''>";
                $cate_arr .= "<td>".$i++."</td>";
                $cate_arr .= "<td style='text-align:left;'>&nbsp;&nbsp;&nbsp;├&nbsp;&nbsp;&nbsp;".str_repeat("&nbsp;&nbsp;&nbsp;├&nbsp;&nbsp;&nbsp;",$lev).$v['username']."&nbsp;&nbsp;".$v['mc']."</td>";
                $cate_arr .= "<td>".$v['je']."</td>
								<td>{$v['dlyj']}</td>
								<td>{$v['dml']}</td>
								<td>{$v['zjzje']}</td>
								<td>{$v['zcjje']}</td>
								<td>{$v['czzje']}</td>
							  <td>{$v['tzzje']}</td>
							  <td>{$v['txzje']}</td>";
                if(!input('get.url')){
                    $cate_arr .= "<td style='text-align:center;'>";
                    if($v['dl']!='1'){
                        $cate_arr .= "<a href='/admin/Member/us_dlzy?uid={$v['id']}'>转移</a>";
                    }


                    $cate_arr .= "</td>";
                }
                $cate_arr .= "</tr>";
                $xiaoji['dlyj'] += $v['dlyj'];
                $xiaoji['je'] += $v['je'];
                $xiaoji['dml'] += $v['dml'];
                $xiaoji['zjzje'] += $v['zjzje'];
                $xiaoji['zcjje'] += $v['zcjje'];
                $xiaoji['czzje'] += $v['czzje'];
                $xiaoji['tzzje'] += $v['tzzje'];
                $xiaoji['txzje'] += $v['txzje'];
                szt($arr,$v['id'],$lev+1);
            }
        }
    }
    $category = [$cate_arr,$xiaoji,$i-1];
    return $category;
}

// 验证投注号码的注数
function touzhu_hm_code_zhushu($wfid,$tzhm,$lottery_class_id) {
    $tzzs = 0;

    /* 时时彩 */
    if($lottery_class_id == '1') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }

        $arr_1 = explode (' ',trim($tzhm_arr[0]));
        if(count($tzhm_arr) == 2) {
            $arr_2 = explode (' ',trim($tzhm_arr[1]));
            $intersect_length = count(array_intersect($arr_1,$arr_2));
        }

        $tzhm_deal_count = 0;
        /* -------------------------固定替换特殊处理(三星直选跨度专用)---------------------------- */
        if($wfid == 23 || $wfid == 29 || $wfid == 35) {
            foreach($arr_1 as $vd) {
                if($vd == '0') $tzhm_deal_count += 10;
                if($vd == '1' || $vd == '9') $tzhm_deal_count += 54;
                if($vd == '2' || $vd == '8') $tzhm_deal_count += 96;
                if($vd == '3' || $vd == '7') $tzhm_deal_count += 126;
                if($vd == '4' || $vd == '6') $tzhm_deal_count += 144;
                if($vd == '5') $tzhm_deal_count += 150;
            }
        }
        /* --------------------------------固定替换特殊处理结束------------------------------------- */

        /* -------------------------固定替换特殊处理(二星直选跨度专用)---------------------------- */
        if($wfid == 41 || $wfid == 46) {
            foreach($arr_1 as $vd) {
                if($vd == '0') $tzhm_deal_count += 10;
                if($vd == '1') $tzhm_deal_count += 18;
                if($vd == '2') $tzhm_deal_count += 16;
                if($vd == '3') $tzhm_deal_count += 14;
                if($vd == '4') $tzhm_deal_count += 12;
                if($vd == '5') $tzhm_deal_count += 10;
                if($vd == '6') $tzhm_deal_count += 8;
                if($vd == '7') $tzhm_deal_count += 6;
                if($vd == '8') $tzhm_deal_count += 4;
                if($vd == '9') $tzhm_deal_count += 2;
            }
        }
        /* --------------------------------固定替换特殊处理结束------------------------------------- */

        /* ---------------------------固定替换特殊处理(三星直选和值专用)------------------------------- */
        if($wfid == 22 || $wfid == 28 || $wfid == 34) {
            foreach($arr_1 as $vd) {
                if($vd == '0' || $vd == '27') $tzhm_deal_count += 1;
                if($vd == '1' || $vd == '26') $tzhm_deal_count += 3;
                if($vd == '2' || $vd == '25') $tzhm_deal_count += 6;
                if($vd == '3' || $vd == '24') $tzhm_deal_count += 10;
                if($vd == '4' || $vd == '23') $tzhm_deal_count += 15;
                if($vd == '5' || $vd == '22') $tzhm_deal_count += 21;
                if($vd == '6' || $vd == '21') $tzhm_deal_count += 28;
                if($vd == '7' || $vd == '20') $tzhm_deal_count += 36;
                if($vd == '8' || $vd == '19') $tzhm_deal_count += 45;
                if($vd == '9' || $vd == '18') $tzhm_deal_count += 55;
                if($vd == '10' || $vd == '17') $tzhm_deal_count += 63;
                if($vd == '11' || $vd == '16') $tzhm_deal_count += 69;
                if($vd == '12' || $vd == '15') $tzhm_deal_count += 73;
                if($vd == '13' || $vd == '14') $tzhm_deal_count += 75;
            }
        }
        /* ---------------------------------固定替换特殊处理结束-------------------------------------- */

        /* ---------------------------固定替换特殊处理(二星直选和值专用)------------------------------- */
        if($wfid == 40 || $wfid == 45) {
            foreach($arr_1 as $vd) {
                if($vd == '0' || $vd == '18') $tzhm_deal_count += 1;
                if($vd == '1' || $vd == '17') $tzhm_deal_count += 2;
                if($vd == '2' || $vd == '16') $tzhm_deal_count += 3;
                if($vd == '3' || $vd == '15') $tzhm_deal_count += 4;
                if($vd == '4' || $vd == '14') $tzhm_deal_count += 5;
                if($vd == '5' || $vd == '13') $tzhm_deal_count += 6;
                if($vd == '6' || $vd == '12') $tzhm_deal_count += 7;
                if($vd == '7' || $vd == '11') $tzhm_deal_count += 8;
                if($vd == '8' || $vd == '10') $tzhm_deal_count += 9;
                if($vd == '9') $tzhm_deal_count += 10;
            }
        }
        /* ---------------------------------固定替换特殊处理结束-------------------------------------- */

        switch($wfid) {
            case '1':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2] * $hcount[3] * $hcount[4]; break;
            case '2':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2] * $hcount[3] * $hcount[4] * 5; break;
            case '3':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) * ($hcount[0]-4) / 120; break;
            case '4':
                $tzzs = ($hcount[1]-1)*($hcount[1]-2)*($hcount[1]-3)/6*$intersect_length + ($hcount[0]-$intersect_length)*$hcount[1]*($hcount[1]-1)*($hcount[1]-2)/6; break;
            case '5':
                $tzzs = ($hcount[0]-1)*($hcount[0]-2)/2*$intersect_length + ($hcount[1]-$intersect_length)*$hcount[0]*($hcount[0]-1)/2; break;
            case '6':
                $tzzs = ($hcount[1]-1)*($hcount[1]-2)/2*$intersect_length + ($hcount[0]-$intersect_length)*$hcount[1]*($hcount[1]-1)/2; break;
            case '7':
                $tzzs = $hcount[0] * $hcount[1] - $intersect_length; break;
            case '8':
                $tzzs = $hcount[0] * $hcount[1] - $intersect_length; break;
            case '9':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2] * $hcount[3]; break;
            case '10':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2] * $hcount[3] * 4; break;
            case '11':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) / 24; break;
            case '12':
                $tzzs = ($hcount[1]-1)*($hcount[1]-2)/2*$intersect_length + ($hcount[0]-$intersect_length)*$hcount[1]*($hcount[1]-1)/2; break;
            case '13':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '14':
                $tzzs = $hcount[0] * $hcount[1] - $intersect_length; break;
            case '15':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2] * $hcount[3]; break;
            case '16':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2] * $hcount[3] * 4; break;
            case '17':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) / 24; break;
            case '18':
                $tzzs = ($hcount[1]-1) * ($hcount[1]-2 )/ 2 * $intersect_length + ($hcount[0]-$intersect_length) * $hcount[1] * ($hcount[1]-1) / 2; break;
            case '19':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '20':
                $tzzs = $hcount[0] * $hcount[1] - $intersect_length; break;
            case '21':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2]; break;
            case '22':
                $tzzs = $tzhm_deal_count; break;
            case '23':
                $tzzs = $tzhm_deal_count; break;
            case '24':
                $tzzs = $hcount[0]; break;
            case '25':
                $tzzs = $hcount[0] * ($hcount[0]-1); break;
            case '26':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '27':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2]; break;
            case '28':
                $tzzs = $tzhm_deal_count; break;
            case '29':
                $tzzs = $tzhm_deal_count; break;
            case '30':
                $tzzs = $hcount[0]; break;
            case '31':
                $tzzs = $hcount[0] * ($hcount[0]-1); break;
            case '32':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '33':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2]; break;
            case '34':
                $tzzs = $tzhm_deal_count; break;
            case '35':
                $tzzs = $tzhm_deal_count; break;
            case '36':
                $tzzs = $hcount[0]; break;
            case '37':
                $tzzs = $hcount[0] * ($hcount[0]-1); break;
            case '38':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '39':
                $tzzs = $hcount[0] * $hcount[1]; break;
            case '40':
                $tzzs = $tzhm_deal_count; break;
            case '41':
                $tzzs = $tzhm_deal_count; break;
            case '42':
                $tzzs = $hcount[0]; break;
            case '43':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '44':
                $tzzs = $hcount[0] * $hcount[1]; break;
            case '45':
                $tzzs = $tzhm_deal_count; break;
            case '46':
                $tzzs = $tzhm_deal_count; break;
            case '47':
                $tzzs = $hcount[0]; break;
            case '48':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '49':
                $tzzs = $hcount[0] + $hcount[1] + $hcount[2] + $hcount[3] + $hcount[4]; break;
            case '50':
                $tzzs = $hcount[0]; break;
            case '51':
                $tzzs = $hcount[0]; break;
            case '52':
                $tzzs = $hcount[0]; break;
            case '53':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '54':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '55':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '56':
                $tzzs = $hcount[0]; break;
            case '57':
                $tzzs = $hcount[0]; break;
            case '58':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '59':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '60':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '61':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '62':
                $tzzs = $hcount[0]; break;
            case '63':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '64':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '65':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) / 24; break;
            case '66':
                $tzzs = any_two($hcount[0],$hcount[1],$hcount[2],$hcount[3],$hcount[4]); break;
            case '67':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2 * $hcount[1] * ($hcount[1]-1) / 2; break;
            case '68':
                $tzzs = any_three($hcount[0],$hcount[1],$hcount[2],$hcount[3],$hcount[4]); break;
            case '69':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6 * $hcount[1] * ($hcount[1]-1); break;
            case '70':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6 * $hcount[1] * ($hcount[1]-1) * ($hcount[1]-2) / 6; break;
            case '71':

                $tzzs = any_four($hcount[0],$hcount[1],$hcount[2],$hcount[3],$hcount[4]); break;
            case '72':
                $tzzs = $hcount[0]; break;
            case '73':
                $tzzs = $hcount[0]; break;
            case '74':
                $tzzs = $hcount[0]; break;
            case '75':
                $tzzs = $hcount[0]; break;
            case '76':
                $tzzs = $hcount[0]; break;
            case '77':
                $tzzs = $hcount[0]; break;
            case '78':
                $tzzs = $hcount[0]; break;
            case '79':
                $tzzs = $hcount[0]; break;
            case '80':
                $tzzs = $hcount[0]; break;
            case '81':
                $tzzs = $hcount[0]; break;
            case '82':
                $tzzs = $hcount[0]; break;
            case '83':
                $tzzs = $hcount[0]; break;
            case '84':
                $tzzs = $hcount[0]; break;
            case '85':
                $tzzs = $hcount[0]; break;
            case '86':
                $tzzs = $hcount[0]; break;
            case '87':
                $tzzs = $hcount[0]; break;
            case '88':
                $tzzs = $hcount[0]; break;
            case '89':
                $tzzs = $hcount[0]; break;
            case '90':
                $tzzs = $hcount[0]; break;
            case '91':
                $tzzs = $hcount[0]; break;
            case '92':
                $hcount[0] = $hcount[0] ? $hcount[0] : 1;
                $hcount[1] = $hcount[1] ? $hcount[1] : 1;
                $hcount[2] = $hcount[2] ? $hcount[2] : 1;
                $hcount[3] = $hcount[3] ? $hcount[3] : 1;
                $hcount[4] = $hcount[4] ? $hcount[4] : 1;
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2] * $hcount[3] * $hcount[4]; break;
            case '93':
                $tzzs = $hcount[0]; break;
            case '94':
                $tzzs = $hcount[0]; break;
            case '95':
                $tzzs = $hcount[0]; break;
            case '96':
                $tzzs = $hcount[0]; break;
            case '296':
                $tzzs = $hcount[0] + $hcount[1] + $hcount[2] + $hcount[3] + $hcount[4]; break;
            case '297':
                $tzzs = $hcount[0] + $hcount[1] + $hcount[2] + $hcount[3] + $hcount[4]+ $hcount[5]; break;
            case '298':
                $tzzs = $hcount[0] + $hcount[1] + $hcount[2]; break;
            default:
                $tzzs = 0;
        }
    }

    /* 快三 */
    if($lottery_class_id == '2') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }

        switch($wfid) {
            case '97':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '98':
                $tzzs = $hcount[0] * $hcount[1]; break;
            case '99':
                $tzzs = $hcount[0] * $hcount[1]; break;
            case '100':
                $tzzs = $hcount[0]; break;
            case '101':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '102':
                $tzzs = $hcount[0]; break;
            case '103':
                if($hcount[0]) {
                    $tzzs = 1;
                }
                break;
            case '104':
                if($hcount[0]) {
                    $tzzs = 1;break;
                }
            case '105':
                $tzzs = $hcount[0]; break;
            case '290':
                //三不同号拖胆
                if( isset($hcount[0]) && isset($hcount[1]) ){
                    2==$hcount[0] && $tzzs = $hcount[1];
                    1==$hcount[0] && $tzzs = $hcount[1]*($hcount[1]-1)/2;
                }
                break;
            default:
                $tzzs = 0;
        }
    }

    /* 十一选五 */
    if($lottery_class_id == '3') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }

        switch($wfid) {
            case '106':
                if(count($tzhm_arr) == 3) {
                    $hm_count_1 = explode (' ',$tzhm_arr[0]);
                    $hm_count_2 = explode (' ',$tzhm_arr[1]);
                    $hm_count_3 = explode (' ',$tzhm_arr[2]);
                    foreach($hm_count_1 as &$q) {
                        foreach($hm_count_2 as &$w) {
                            foreach($hm_count_3 as &$e) {
                                if(($q != $w) && ($q != $e) && ($w != $e) && $q && $w && $e) {
                                    $tzzs += 1;
                                }
                            }
                        }
                    }
                }
                break;
            case '107':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '108':
                if(count($tzhm_arr) == 2) {
                    $hm_count_1 = explode (' ',$tzhm_arr[0]);
                    $hm_count_2 = explode (' ',$tzhm_arr[1]);
                    foreach($hm_count_1 as &$q) {
                        foreach($hm_count_2 as &$w) {
                            if(($q != $w)  && $q && $w) {
                                $tzzs += 1;
                            }
                        }
                    }
                }
                break;
            case '109':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '110':
                $tzzs = $hcount[0]; break;
            case '111':
                $tzzs = $hcount[0]+$hcount[1]+$hcount[2]+$hcount[3]+$hcount[4]; break;
            case '112':
                $tzzs = $hcount[0]; break;
            case '113':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '114':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '115':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) / 24; break;
            case '116':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) * ($hcount[0]-4) / 120; break;
            case '117':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) * ($hcount[0]-4) * ($hcount[0]-5) / 720; break;
            case '118':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) * ($hcount[0]-4) * ($hcount[0]-5) * ($hcount[0]-6) / 5040; break;
            case '119':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) * ($hcount[0]-3) * ($hcount[0]-4) * ($hcount[0]-5) * ($hcount[0]-6) * ($hcount[0]-7) / 40320; break;
            case '294':
            	$tzzs = $hcount[0]+$hcount[1]+$hcount[2]+$hcount[3]+$hcount[4]; break;
            case '295':
                $tzzs = $hcount[0]+$hcount[1]+$hcount[2]+$hcount[3]+$hcount[4]+$hcount[5]; break;
            default:
                $tzzs = 0;
        }
    }

    /* PC蛋蛋 */
    if($lottery_class_id == '4') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }
        $tzzs = $hcount[0];
    }

    /* PK10 */
    if($lottery_class_id == '5') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }
        switch($wfid) {
            case '121':
                $tzzs = $hcount[0]; break;
            case '122':
                if(count($tzhm_arr) == 2) {
                    $hm_count_1 = explode (' ',$tzhm_arr[0]);
                    $hm_count_2 = explode (' ',$tzhm_arr[1]);
                    foreach($hm_count_1 as &$q) {
                        foreach($hm_count_2 as &$w) {
                            if(($q != $w)  && $q && $w) {
                                $tzzs += 1;
                            }
                        }
                    }
                }
                break;
            case '123':
                if(count($tzhm_arr) == 3) {
                    $hm_count_1 = explode (' ',$tzhm_arr[0]);
                    $hm_count_2 = explode (' ',$tzhm_arr[1]);
                    $hm_count_3 = explode (' ',$tzhm_arr[2]);
                    foreach($hm_count_1 as &$q) {
                        foreach($hm_count_2 as &$w) {
                            foreach($hm_count_3 as &$e) {
                                if(($q != $w) && ($q != $e) && ($w != $e) && $q && $w && $e) {
                                    $tzzs += 1;
                                }
                            }
                        }
                    }
                }
                break;
            case '124':
                $tzzs = $hcount[0] + $hcount[1] + $hcount[2] + $hcount[3] + $hcount[4]; break;
            case '125':
                $tzzs = $hcount[0] + $hcount[1] + $hcount[2] + $hcount[3] + $hcount[4]; break;
            case '126':
                $tzzs = $hcount[0]; break;
            case '127':
                $tzzs = $hcount[0]; break;
            case '128':
                $tzzs = $hcount[0]; break;
            case '129':
                $tzzs = $hcount[0]; break;
            case '130':
                $tzzs = $hcount[0]; break;
            case '131':
                $tzzs = $hcount[0]; break;
            case '132':
                $tzzs = $hcount[0]; break;
            case '133':
                $tzzs = $hcount[0]; break;
            case '134':
                $tzzs = $hcount[0]; break;
            case '135':
                $tzzs = $hcount[0]; break;
            case '136':
                $tzzs = $hcount[0]; break;
            case '137':
                $tzzs = $hcount[0]; break;
            case '138':
                $tzzs = $hcount[0]; break;
            case '139':
                $tzzs = $hcount[0]; break;
            case '140':
                $tzzs = $hcount[0]; break;
            case '141':
                $tzzs = $hcount[0]; break;
            case '292':
                $tzzs = array_sum($hcount); break;
            case '293':
            	$tzzs = $hcount[0] + $hcount[1] + $hcount[2] + $hcount[3] + $hcount[4]+$hcount[5] + $hcount[6] + $hcount[7] + $hcount[8] + $hcount[9];
            	break;
            case '299':
                $tzzs = $hcount[0]; break;
                break;
            default:
                $tzzs = 0;
        }
    }

    /* 上海时时乐、福彩3D、排列三 */
    if($lottery_class_id == '6') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }
        $arr_1 = explode (' ',trim($tzhm_arr[0]));

        $tzhm_deal_count = 0;
        /* ---------------------------固定替换特殊处理(三码直选和值专用)------------------------------- */
        if($wfid == 143) {
            foreach($arr_1 as $vd) {
                if($vd == '0' || $vd == '27') $tzhm_deal_count += 1;
                if($vd == '1' || $vd == '26') $tzhm_deal_count += 3;
                if($vd == '2' || $vd == '25') $tzhm_deal_count += 6;
                if($vd == '3' || $vd == '24') $tzhm_deal_count += 10;
                if($vd == '4' || $vd == '23') $tzhm_deal_count += 15;
                if($vd == '5' || $vd == '22') $tzhm_deal_count += 21;
                if($vd == '6' || $vd == '21') $tzhm_deal_count += 28;
                if($vd == '7' || $vd == '20') $tzhm_deal_count += 36;
                if($vd == '8' || $vd == '19') $tzhm_deal_count += 45;
                if($vd == '9' || $vd == '18') $tzhm_deal_count += 55;
                if($vd == '10' || $vd == '17') $tzhm_deal_count += 63;
                if($vd == '11' || $vd == '16') $tzhm_deal_count += 69;
                if($vd == '12' || $vd == '15') $tzhm_deal_count += 73;
                if($vd == '13' || $vd == '14') $tzhm_deal_count += 75;
            }
        }
        /* ---------------------------------固定替换特殊处理结束-------------------------------------- */

        /* ---------------------------固定替换特殊处理(二码直选和值专用)------------------------------- */
        if($wfid == 147 || $wfid == 150) {
            foreach($arr_1 as $vd) {
                if($vd == '0' || $vd == '18') $tzhm_deal_count += 1;
                if($vd == '1' || $vd == '17') $tzhm_deal_count += 2;
                if($vd == '2' || $vd == '16') $tzhm_deal_count += 3;
                if($vd == '3' || $vd == '15') $tzhm_deal_count += 4;
                if($vd == '4' || $vd == '14') $tzhm_deal_count += 5;
                if($vd == '5' || $vd == '13') $tzhm_deal_count += 6;
                if($vd == '6' || $vd == '12') $tzhm_deal_count += 7;
                if($vd == '7' || $vd == '11') $tzhm_deal_count += 8;
                if($vd == '8' || $vd == '10') $tzhm_deal_count += 9;
                if($vd == '9') $tzhm_deal_count += 10;
            }
        }
        /* ---------------------------------固定替换特殊处理结束-------------------------------------- */

        switch($wfid) {
            case '142':
                $tzzs = $hcount[0] * $hcount[1] * $hcount[2]; break;
            case '143':
                $tzzs = $tzhm_deal_count; break;
            case '144':
                $tzzs = $hcount[0] * ($hcount[0]-1); break;
            case '145':
                $tzzs = $hcount[0] * ($hcount[0]-1) * ($hcount[0]-2) / 6; break;
            case '146':
                $tzzs = $hcount[0] * $hcount[1]; break;
            case '147':
                $tzzs = $tzhm_deal_count; break;
            case '148':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '149':
                $tzzs = $hcount[0] * $hcount[1]; break;
            case '150':
                $tzzs = $tzhm_deal_count; break;
            case '151':
                $tzzs = $hcount[0] * ($hcount[0]-1) / 2; break;
            case '152':
                $tzzs = $hcount[0] + $hcount[1] + $hcount[2]; break;
            case '153':
                $tzzs = $hcount[0]; break;
            default:
                $tzzs = 0;
        }
    }

    //六合彩
    if($lottery_class_id == '8') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }

        switch($wfid) {
            case '163':
                $tzzs = $hcount[0]; break;
            case '164':
                $tzzs = $hcount[0]; break;
            case '165':
                $tzzs = $hcount[0]; break;
            case '291':
                $tzzs = $hcount[0]; break;
            case '166':
                $tzzs = $hcount[0]; break;
            case '167':
                $tzzs = $hcount[0]; break;
            case '168':
                $tzzs = $hcount[0]; break;
            case '169':
                $tzzs = $hcount[0]; break;
            case '170':
                $tzzs = $hcount[0]; break;
            case '171':
                $tzzs = $hcount[0]; break;
            case '172':
                $tzzs = $hcount[0]; break;
            case '173':
                $tzzs = 0;
                foreach($hcount as $v) {
                    if($v > 0) {
                        $tzzs++;
                    }
                }
                $tzzs = $tzzs>1 ? 1 : 0;
                break;
            case '174':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)/24; break;
            case '181':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)/6; break;
            case '188':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)/6; break;
            case '195':
                $tzzs = $hcount[0]*($hcount[0]-1)/2; break;
            case '204':
                $tzzs = $hcount[0]*($hcount[0]-1)/2; break;
            case '213':
                $tzzs = $hcount[0]*($hcount[0]-1)/2; break;
            case '222':
                $tzzs = $hcount[0]*($hcount[0]-1)/2; break;
            case '223':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)/6; break;
            case '224':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)/24; break;
            case '225':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)/120; break;
            case '226':
                $tzzs = $hcount[0]*($hcount[0]-1)/2; break;
            case '227':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)/6; break;
            case '228':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)/24; break;
            case '229':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)/120; break;
            case '230':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)/120; break;
            case '231':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)/720; break;
            case '232':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)/5040; break;
            case '233':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)/40320; break;
            case '234':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)*($hcount[0]-8)/362880; break;
            case '235':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)*($hcount[0]-8)*($hcount[0]-9)/3628800; break;
            case '236':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)*($hcount[0]-8)*($hcount[0]-9)*($hcount[0]-10)/39916800; break;
            case '237':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)*($hcount[0]-8)*($hcount[0]-9)*($hcount[0]-10)*($hcount[0]-11)/479001600; break;
            case '238':
                $tzzs = $hcount[0]; break;
            case '239':
                $tzzs = $hcount[0]; break;
            case '240':
                $tzzs = $hcount[0]; break;
            case '241':
                $tzzs = $hcount[0]; break;
            case '242':
                $tzzs = 0;
                if($hcount[0] >= 1 && $hcount[0] <= 12) $tzzs = 1;
                break;
            case '250':
                $tzzs = $hcount[0]; break;
            case '251':
                $tzzs = $hcount[0]; break;
            case '252':
                $tzzs = $hcount[0]; break;
            case '253':
                $tzzs = $hcount[0]; break;
            case '254':
                $tzzs = $hcount[0]; break;
            case '255':
                $tzzs = $hcount[0]; break;
            case '256':
                $tzzs = $hcount[0]; break;
            case '289':
                $tzzs = $hcount[0]; break;
            case '257':
                $tzzs = $hcount[0]; break;
            case '258':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)/120; break;
            case '259':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)/720; break;
            case '260':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)/5040; break;
            case '261':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)/40320; break;
            case '262':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)*($hcount[0]-8)/362880; break;
            case '263':
                $tzzs = $hcount[0]*($hcount[0]-1)*($hcount[0]-2)*($hcount[0]-3)*($hcount[0]-4)*($hcount[0]-5)*($hcount[0]-6)*($hcount[0]-7)*($hcount[0]-8)*($hcount[0]-9)/3628800; break;
            default:
                $tzzs = 0;
        }
    }
    /* 七星彩 */
    if($lottery_class_id == '9') {
        //拆分号码
        $tzhm_arr = explode (',',$tzhm);
        $tzhm_arr = array_map('trim',$tzhm_arr);
        foreach($tzhm_arr as $k=>&$v) {
            $v = trim($v);
            if($v !== '') {
                $hcount[$k] = count(explode (' ',$v));
            } else {
                $hcount[$k] = 0;
            }
        }

        switch($wfid) {
            case '264':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]*$hcount[3]*$hcount[4]*$hcount[5]*$hcount[6]; break;
            case '265':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]*$hcount[3]*$hcount[4]*$hcount[5]; break;
            case '266':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]*$hcount[3]*$hcount[4]*$hcount[5]; break;
            case '267':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]*$hcount[3]*$hcount[4]; break;
            case '268':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]*$hcount[3]*$hcount[4]; break;
            case '269':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]*$hcount[3]; break;
            case '270':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]*$hcount[3]; break;
            case '271':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]; break;
            case '272':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]; break;
            case '273':
                $tzzs = $hcount[0]*$hcount[1]*$hcount[2]; break;
            case '274':
                $tzzs = $hcount[0]*$hcount[1]; break;
            case '275':
                $tzzs = $hcount[0]*$hcount[1]; break;
            case '276':
                $tzzs = $hcount[0]+$hcount[1]+$hcount[2]+$hcount[3]+$hcount[4]+$hcount[5]+$hcount[6]; break;
            default :
                $tzzs = 0;
        }
    }
    return $tzzs;
}


//任意二星
function any_two($wan,$qian,$bai,$shi,$ge){
    $wan = $wan ? $wan : 0;
    $qian = $qian ? $qian : 0;
    $bai = $bai ? $bai : 0;
    $shi = $shi ? $shi : 0;
    $ge = $ge ? $ge : 0;
    $zhushu = $wan*($ge+$shi+$bai+$qian) + $qian*($ge+$shi+$bai) + $bai*($ge+$shi) + $shi*$ge;
    return $zhushu;
}
//任意三星
function any_three($wan,$qian,$bai,$shi,$ge){
    $zhushu = $wan*any_two($ge,$shi,$bai,$qian,0) + $qian*any_two($ge,$shi,$bai,0,0) + $bai*any_two($ge,$shi,0,0,0);
    return $zhushu;
}
//任意四星
function any_four($wan,$qian,$bai,$shi,$ge) {
    $zhushu = ($wan*$qian*$bai*$shi) + ($wan*$qian*$bai*$ge) + ($wan*$qian*$shi*$ge) + ($wan*$bai*$shi*$ge) + ($qian*$bai*$shi*$ge);
    return $zhushu;
}
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
function timeSelection($day=''){
    //今天
    if($day=='0' || $day==''){
        $start = strtotime(date('Y-m-d').' 00:00:00');
        $end = strtotime(date('Y-m-d').' 23:59:59');

    }
    //昨天
    if($day=='4'){
        $start = strtotime(date("Y-m-d",strtotime("-1 day")).' 00:00:00');
        $end = strtotime(date("Y-m-d",strtotime("-1 day")).' 23:59:59');

    }
    //本周
    if($day=='1'){
        $start = strtotime(date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)).' 00:00:00');
        $end = strtotime(date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)).' 23:59:59');

    }
    //上周
    if($day=='5'){
        $start = mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
        $end = mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));

    }
    //本月
    if($day=='2'){
        $start = strtotime(date('Y-m-d', strtotime(date('Y-m', time()) . '-01 00:00:00')).' 00:00:00');
        $end = strtotime(date('Y-m-d', strtotime(date('Y-m', time()) . '-' . date('t', time()) . ' 00:00:00')).' 23:59:59');

    }
    //上月
    if($day=='3'){
        $start = strtotime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m', time()) . '-01 00:00:00'))).' 00:00:00');
        $end = strtotime(date('Y-m-d', strtotime(date('Y-m', time()) . '-01 00:00:00') - 86400).' 23:59:59');

    }
    //今年
    if($day=='6'){
        $start = strtotime(date('Y').'-1-1 00:00:00');
        $end = strtotime(date('Y').'-12-31 23:59:59');

    }
    $time = [$start,$end];
    return $time;
}

function getExtInfo($gameid,$kjjg){

    $arr = array('has'=>0,'zh'=>0,'ds'=>'和','dx'=>'大');
    if( in_array( intval($gameid),[44,36,62,1,8,51,9,10,16,25,28,72]) ) {
        $arr['has'] = 1;
        $arr['zh'] = array_sum($kjjg);
        $arr['ds'] = ( 0==intval($arr['zh'])%2 ) ? '双' : '单';
    }
    switch( intval($gameid) ){
        case 36:
        case 44:
        case 72:
            //江苏快三、安徽快三、极速快三
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),10);
            break;
        case 62:
        case 1:
        case 8:
            //分分时时彩、重庆时时彩、天津时时彩
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),22);
            break;
        case 51:
            //七星彩
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),31);
            break;
        case 9:
            //港彩⑥合
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),150,150);
            break;
        case 10:
            //新加坡28
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),13);
            break;
        case 16:
        case 25:
        case 28:
            //广东11选5、江西11选5、山东11选5
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),30,30);
            break;
        case 5:
        case 7:
        case 48:
            //排列三、福彩3D、上海时时乐
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),13);
            break;
        case 49:
        case 59:
            //广东快乐十分、重庆快乐十分
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),84,84);
            break;
        case 60:
            //北京快乐8
            $arr['dx'] = getBigOrSmall(intval($arr['zh']),810,810);
            break;
    }
    return $arr;
}

function useTemplate($source,$destination,$bind){
    //打开并读取模板内容
    if( !$handle_r = fopen($source,"r") ) return false;
    if( !$str = fread($handle_r,filesize($source)) ) return false;
    $str = str_replace(array_keys($bind),array_values($bind),$str);
    if( !fclose($handle_r) ) return false;
    if( !$handle = fopen($destination,"w") ) return false;
    if( !fwrite($handle,$str) ) return false;
    if( !fclose($handle) ) return false;
    return true;
}

//----------------------BEGIN:获取中文字符串的首字母拼接字符串--------------------//
function getfirstchar($s0){
    $fchar = ord($s0{0});
    if($fchar >= ord("A") and $fchar <= ord("z") )return strtoupper($s0{0});
    //$s1 = iconv("UTF-8","gb2312//IGNORE", $s0);
    // $s2 = iconv("gb2312","UTF-8//IGNORE", $s1);
    $s1 = get_encoding($s0,'GB2312');
    $s2 = get_encoding($s1,'UTF-8');
    if($s2 == $s0){$s = $s1;}else{$s = $s0;}
    $asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
    if($asc >= -20319 and $asc <= -20284) return "A";
    if($asc >= -20283 and $asc <= -19776) return "B";
    if($asc >= -19775 and $asc <= -19219) return "C";
    if($asc >= -19218 and $asc <= -18711) return "D";
    if($asc >= -18710 and $asc <= -18527) return "E";
    if($asc >= -18526 and $asc <= -18240) return "F";
    if($asc >= -18239 and $asc <= -17923) return "G";
    if($asc >= -17922 and $asc <= -17418) return "I";
    if($asc >= -17417 and $asc <= -16475) return "J";
    if($asc >= -16474 and $asc <= -16213) return "K";
    if($asc >= -16212 and $asc <= -15641) return "L";
    if($asc >= -15640 and $asc <= -15166) return "M";
    if($asc >= -15165 and $asc <= -14923) return "N";
    if($asc >= -14922 and $asc <= -14915) return "O";
    if($asc >= -14914 and $asc <= -14631) return "P";
    if($asc >= -14630 and $asc <= -14150) return "Q";
    if($asc >= -14149 and $asc <= -14091) return "R";
    if($asc >= -14090 and $asc <= -13319) return "S";
    if($asc >= -13318 and $asc <= -12839) return "T";
    if($asc >= -12838 and $asc <= -12557) return "W";
    if($asc >= -12556 and $asc <= -11848) return "X";
    if($asc >= -11847 and $asc <= -11056) return "Y";
    if($asc >= -11055 and $asc <= -10247) return "Z";
    return null;
}
/**
 * @name: get_encoding
 * @description: 自动检测内容编码进行转换
 * @param: string data
 * @param: string to  目标编码
 * @return: string
 **/
function get_encoding($data,$to){
    $encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');
    $encoded = mb_detect_encoding($data, $encode_arr);
    $data = mb_convert_encoding($data,$to,$encoded);
    return $data;
}
function ChineseToPY($zh){
    $ret = "";
    $s1 = iconv("UTF-8","gb2312", $zh);
    $s2 = iconv("gb2312","UTF-8", $s1);
    if($s2 == $zh){$zh = $s1;}
    for($i = 0; $i < strlen($zh); $i++){
        $s1 = substr($zh,$i,1);
        $p = ord($s1);
        if($p > 160){
            $s2 = substr($zh,$i++,2);
            $ret .= getfirstchar($s2);
        }else{
            $ret .= $s1;
        }
    }
    return strtolower($ret);
}
//-----------------------END:获取中文字符串的首字母拼接字符串--------------------//
//-----------------------------------发送邮件--------------------------------------//
function setEmail($title,$message,$destination)
{
    $mail = new \PHPMailer\PHPMailer();
    $mail->isSMTP();// 使用SMTP服务
    $mail->SMTPAuth    = true;
    $mail->CharSet    = "utf-8";	
    $mail->Port        = 25;
    $mail->Host = "smtp.163.com";
    $mail->Username = "bushishenxian135@163.com";
    $mail->Password = "6709a1";
    $mail->From        = "bushishenxian135@163.com";
    $mail->FromName    = "赢彩提醒";
    $mail->AddAddress($destination);
    $mail->Subject   = $title;
    $mail->MsgHTML($message);
    $mail->IsHTML(true); // send as HTML
    if (!$mail->send()) {// 发送邮件
        echo "Mailer Error: " . $mail->ErrorInfo;// 输出错误信息
    } else {
        echo 1;  //成功
    }
}